package com.mx.controller;

import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mengbin
 * @date 2018年1月18日 上午11:29:24
 */
@RestController
public class FirstController {
    
    public static boolean isHealth = true;
    
    @Value("${server.port}")
    private String port;

    @RequestMapping("/find")
    public Object find() throws Exception {
        Map<String, Object> map = new HashMap<>();
        map.put("success", true);
        map.put("port", port);
        map.put("ip", InetAddress.getLocalHost().getHostName());
        return map;
    }
    
    @RequestMapping("/health/{health}")
    public Object health(@PathVariable Boolean health) {
        isHealth = health;
        return "success";
    }
}
